{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "                                   Open          High           Low  \\\n",
      "Date                                                                  \n",
      "2024-11-23 00:00:00+00:00  99006.742188  99014.679688  97232.890625   \n",
      "2024-11-24 00:00:00+00:00  97778.093750  98647.179688  95788.078125   \n",
      "2024-11-25 00:00:00+00:00  98033.445312  98935.031250  92642.914062   \n",
      "2024-11-26 00:00:00+00:00  93087.281250  94991.750000  90770.812500   \n",
      "2024-11-27 00:00:00+00:00  91978.140625  97361.179688  91778.664062   \n",
      "...                                 ...           ...           ...   \n",
      "2025-02-19 00:00:00+00:00  95532.531250  96855.593750  95011.968750   \n",
      "2025-02-20 00:00:00+00:00  96632.679688  98767.195312  96442.671875   \n",
      "2025-02-21 00:00:00+00:00  98340.671875  99497.968750  94852.960938   \n",
      "2025-02-22 00:00:00+00:00  96134.203125  96950.156250  95765.343750   \n",
      "2025-02-23 00:00:00+00:00  96571.046875  96657.171875  96218.867188   \n",
      "\n",
      "                                  Close       Volume  Dividends  Stock Splits  \n",
      "Date                                                                           \n",
      "2024-11-23 00:00:00+00:00  97777.281250  44414644677        0.0           0.0  \n",
      "2024-11-24 00:00:00+00:00  98013.820312  51712020623        0.0           0.0  \n",
      "2024-11-25 00:00:00+00:00  93102.296875  80909462490        0.0           0.0  \n",
      "2024-11-26 00:00:00+00:00  91985.320312  91656519855        0.0           0.0  \n",
      "2024-11-27 00:00:00+00:00  95962.531250  71133452438        0.0           0.0  \n",
      "...                                 ...          ...        ...           ...  \n",
      "2025-02-19 00:00:00+00:00  96635.609375  28990872862        0.0           0.0  \n",
      "2025-02-20 00:00:00+00:00  98333.937500  31668022771        0.0           0.0  \n",
      "2025-02-21 00:00:00+00:00  96125.546875  49608706470        0.0           0.0  \n",
      "2025-02-22 00:00:00+00:00  96577.757812  18353824477        0.0           0.0  \n",
      "2025-02-23 00:00:00+00:00  96252.078125  15599898624        0.0           0.0  \n",
      "\n",
      "[93 rows x 7 columns]\n"
     ]
    }
   ],
   "source": [
    "import yfinance as yf\n",
    "\n",
    "# 获取股票信息\n",
    "stock = yf.Ticker(\"BTC-USD\")\n",
    "\n",
    "# 获取股票信息\n",
    "info = stock.info\n",
    "\n",
    "# 获取过去一年内的历史数据\n",
    "history = stock.history(period=\"3mo\")\n",
    "\n",
    "# 打印历史数据\n",
    "print(history)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "[*********************100%***********************]  1 of 1 completed\n"
     ]
    }
   ],
   "source": [
    "import yfinance as yf\n",
    "import talib\n",
    "import pandas as pd\n",
    "import matplotlib.pyplot as plt\n",
    "\n",
    "# 获取股票数据（以苹果公司为例）\n",
    "data = yf.download(\"AAPL\", start=\"2023-01-01\", end=\"2025-02-26\")\n",
    "\n",
    "# 计算MACD指标\n",
    "macd, signal, hist = talib.MACD(\n",
    "    data[\"Close\"].values.flatten(), fastperiod=12, slowperiod=26, signalperiod=9\n",
    ")\n"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": ".venv",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.13.1"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
